<template>
  <div class="toolListItem-container">
    <router-link :to="toPath" @click.native="layout"
      >{{ title }}<van-icon name="arrow"
    /></router-link>
  </div>
</template>

<script>
import router from "@/router";
import { Dialog } from "vant";
export default {
  props: {
    title: {
      default: "",
      type: String,
    },
    toPath: {
      default: "",
      type: String,
    },
  },
  methods: {
    layout() {
      if (this.toPath === "") {
        const token = localStorage.getItem("Token");
        if (token) {
          localStorage.removeItem("Token");
          location.reload();
        } else {
          Dialog.confirm({
            title: "退出登录失败",
            message: "您还未登录，请先登录",
          })
            .then(() => {
              router.push("/login");
            })
            .catch(() => {
              router.push("/homemain/mine");
            });
        }
      }
    },
  },
};
</script>

<style lang="less" scoped>
.toolListItem-container {
  width: 100vw;
  a {
    position: relative;
    display: flex;
    align-items: center;
    height: 7vh;
    padding-left: 20px;
    // margin-top: 10px;
    // margin-bottom: 10px;
    background-color: #fff;
    font-size: 15px;
    color: black;
    i {
      position: absolute;
      right: 3vw;
    }
  }
}
</style>